package xin.marcher.module.common.enums.price;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * 价格分类枚举
 */
public enum PriceTypeEnum {

    /**
     * 所有价格
     */
    All_PRICE(0, "所有价格"),
    /**
     * 商城价
     */
    BASE_PRICE(1, "商城价"),
    /**
     * 会员价
     */
    VIP_PRICE(2, "会员价"),

    /**
     * 新人价
     */
    NEW_MEMBER_PRICE(3, "新人价"),

    /**
     * 划线价格
     */
    SCRIBING_PRICE(4, "划线价格"),

    /**
     * 区域定价
     */
    DISTRICT_PRICE(5, "区域定价");

    private Integer code;

    private String value;

    PriceTypeEnum(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    public Integer getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public static Map<Integer, String> toMap() {
        Map<Integer, String> map = Maps.newHashMap();
        for (PriceTypeEnum element : PriceTypeEnum.values()) {
            map.put(element.getCode(), element.getValue());
        }
        return map;
    }

    public static PriceTypeEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (PriceTypeEnum element : PriceTypeEnum.values()) {
            if (code.equals(element.getCode())) {
                return element;
            }
        }
        return null;
    }

}